define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree', 'vue'], function ($, undefined, Backend, Table, Form, undefined, Vue) {
//读取选中的条目
    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'user/member_list',
                    edit_url: 'user/member_list/edit',
                    del_url: 'user/member_list/del'
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                search: false,
                columns: [
                    [
                        {field: 'id', title: 'ID'},
                        {field: 'name', title: __('Name'), operate: 'LIKE %...%', placeholder: '模糊搜索'},
                        {field: 'organization', title: __("Organization"), searchable: false},
                        {field: 'phone', title: __("Phone"), searchable: false},
                        {
                            field: 'user_id',
                            title: __('User Id'),
                            searchable: false,
                            formatter: function (value, row, index) {
                                value = value + '';
                                switch (value) {
                                    case '0':
                                        return __('No User');
                                    default:
                                        return value;
                                }
                            }
                        },
                        {field: 'commit_num', title: __("Commit num"), searchable: false},
                        {
                            field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
                            buttons: [
                                {
                                    name: 'verify_log',
                                    text: __('Verify_num'),
                                    classname: 'btn btn-info btn-xs btn-detail btn-dialog',
                                    url: 'user/member_list/verify_log'
                                },
                                {
                                    name: 'access_log',
                                    text: __('Access log'),
                                    classname: 'btn btn-info btn-xs btn-detail btn-dialog',
                                    url: 'user/member_list/access_log'
                                },
                                {
                                    name: 'login_log',
                                    text: __('Login log'),
                                    classname: 'btn btn-info btn-xs btn-detail btn-dialog',
                                    url: 'user/member_list/login_log'
                                },
                                {
                                    name: 'change_password',
                                    text: __('Change password'),
                                    classname: 'btn btn-info btn-xs btn-detail btn-dialog',
                                    url: 'user/member_list/change_password'
                                }
                            ],
                            formatter: function (value, row, index) {
                                return Table.api.formatter.operate.call(this, value, row, index);
                            }
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        edit: function () {
            Form.api.bindevent($("form[role=form]"));
        },
        add: function () {
            Form.api.bindevent($("form[role=form]"));
        },
        change_password: function () {
            Form.api.bindevent($("form[role=form]"));
        },
        access_log: function () {
            var member_id = Config.member_id;
            Table.api.init({
                extend: {
                    index_url: 'user/member_list/access_log/ids/' + member_id
                }
            });
            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: 'user/member_list/access_log/ids/' + member_id,
                search: false,
                columns: [
                    [
                        {field: 'id', title: 'ID'},
                        {field: 'name', title: __('Name'), searchable: false},
                        {field: 'ip', title: __("Ip"), searchable: false},
                        {field: 'keyword', title: __("Keyword"), searchable: false},
                        {
                            field: 'create_time',
                            title: __("Createtime"),
                            formatter: Table.api.formatter.datetime,
                            searchable: false
                        },
                        {
                            field: 'search_type',
                            title: __('Search type'),
                            formatter: function (value, row, index) {
                                value = value + '';
                                switch (value) {
                                    case '0':
                                        return __('Strain');
                                    case '1':
                                        return __('Bacterial Library');
                                }
                            },
                            searchList: {
                                '0': __('Strain'),
                                '1': __('Bacterial Library'),
                            },
                            style: 'min-width:100px;'
                        },
                        {
                            field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
                            formatter: function (value, row, index) {
                                return Table.api.formatter.operate.call(this, value, row, index);
                            }
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        login_log: function () {
            var member_id = Config.member_id;
            Table.api.init({
                extend: {
                    index_url: 'user/member_list/login_log/ids/' + member_id
                }
            });
            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: 'user/member_list/login_log/ids/' + member_id,
                search: false,
                columns: [
                    [
                        {field: 'id', title: 'ID'},
                        {field: 'name', title: __('Name'), searchable: false},
                        {field: 'ip', title: __("Ip"), searchable: false},
                        {
                            field: 'create_time',
                            title: __("Createtime"),
                            formatter: Table.api.formatter.datetime,
                            searchable: false
                        },
                        {
                            field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
                            formatter: function (value, row, index) {
                                return Table.api.formatter.operate.call(this, value, row, index);
                            }
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        verify_log: function () {
            var member_id = Config.member_id;
            Table.api.init({
                extend: {
                    index_url: 'user/member_list/verify_log/ids/' + member_id
                }
            });
            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: 'user/member_list/verify_log/ids/' + member_id,
                search: false,
                columns: [
                    [
                        {field: 'id', title: 'ID'},
                        {field: 'bacteria_name', title: __('Bacteria name'), operate: 'LIKE %...%', placeholder: '模糊搜索'},
                        {
                            field: 'type',
                            title: __('type'),
                            formatter: function (value, row, index) {
                                value = '' + value;
                                switch (value) {
                                    case '0':
                                        return __('change');
                                    case '1':
                                        return __('push');
                                }
                            },
                            searchList: {'0': __('change'), '1': __('push')},
                            style: 'min-width:100px;'
                        },
                        {
                            field: 'status',
                            title: __('Status'),
                            formatter: function (value, row, index) {
                                value = '' + value;
                                switch (value) {
                                    case '0':
                                        return __('Wait');
                                    case '1':
                                        return __('Verify passed');
                                    case '2':
                                        return __('Verify fail');
                                    default:
                                        return __('Wait');
                                }
                            },
                            searchList: {'0': __('Wait'), '1': __('Verify passed'), '2': __('Verify fail')},
                            style: 'min-width:100px;'
                        },
                        {field: 'desc', title: __('Verify desc'), searchable: false},
                        {
                            field: 'create_time',
                            title: __("Createtime"),
                            formatter: Table.api.formatter.datetime,
                            searchable: false
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        }
    };
    return Controller;
});